home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 September / september_2000.iso / intercd / root / ^Linux / Jooky / dgets.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-11-01  |  424 b   |  30 lines

  1. #include "includes.h"
  2.  
  3. char *dgets(char *s, int size, FILE *stream)
  4. {
  5.     int q;
  6.     char thing;
  7.     char *pointy;
  8.     
  9.     pointy=s;
  10.  
  11.     memset(s,0,size);
  12.  
  13.     for (q=0;q<size;++q)
  14.     {
  15.         thing=fgetc(stream);
  16.         if ((thing==10) || (thing==13) || (thing==0))
  17.         {
  18.             fflush(stdout);
  19.             return (char *)s;
  20.         }
  21.         if (thing==EOF)
  22.         {
  23.             return (char *)NULL;
  24.         }
  25.         memset(pointy+q,(int)thing,1);
  26.     }
  27.     return (char *)NULL;
  28. }
  29.  
  30.